-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ABW-2674] Pool redemption/contribution tx preview types #745
[ABW-2674] Pool redemption/contribution tx preview types #745
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work! Don't forget the todos. Also will this be included in this PR?
@@ -69,6 +69,8 @@ data class PoolWithResourceResponse( | |||
val poolUnitAddress: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can be deleted now, since the same info exists in the poolMetadata.
is TransferableResource.LsuAmount -> GuaranteeAssertion.ForAmount( | ||
amount = transferable.amount * predicted.guaranteeOffset.toBigDecimal(), | ||
instructionIndex = predicted.instructionIndex | ||
) | ||
is TransferableResource.StakeClaimNft -> null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to ask Matt about stake claim NFTs and their assertions?
data class Pool( | ||
val address: String, | ||
val poolUnitAddress: String, | ||
val metadata: List<Metadata>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
@@ -23,10 +23,10 @@ class GetPoolUnitDetailsUseCase @Inject constructor( | |||
val poolAddress = poolResource.poolAddress ?: return@then runCatching { | |||
error("Resource $resourceAddress is not associated with a pool") | |||
} | |||
stateRepository.getPool(poolAddress).map { | |||
stateRepository.getPools(setOf(poolAddress)).map { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use mapCatching
here since first() can throw an exception.
@@ -321,7 +321,7 @@ class TransactionReviewViewModel @Inject constructor( | |||
) | |||
|
|||
val isRawManifestToggleVisible: Boolean | |||
get() = previewType is PreviewType.Transfer | |||
get() = true // previewType is PreviewType.Transfer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this set to always true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, was for testing
sealed interface Transfer : PreviewType { | ||
val from: List<AccountWithTransferableResources> | ||
val to: List<AccountWithTransferableResources> | ||
|
||
data class Staking( | ||
override val from: List<AccountWithTransferableResources>, | ||
override val to: List<AccountWithTransferableResources>, | ||
val validators: List<ValidatorDetail>, | ||
val actionType: ActionType | ||
) : Transfer { | ||
enum class ActionType { | ||
Stake, Unstake, ClaimStake | ||
} | ||
} | ||
|
||
fun getNewlyCreatedResources() = (from + to).map { allTransfers -> | ||
allTransfers.resources.filter { it.transferable.isNewlyCreated }.map { it.transferable } | ||
}.flatten() | ||
} | ||
data class Pool( | ||
override val from: List<AccountWithTransferableResources>, | ||
override val to: List<AccountWithTransferableResources>, | ||
val pools: List<com.babylon.wallet.android.domain.model.resources.Pool>, | ||
val actionType: ActionType | ||
) : Transfer { | ||
enum class ActionType { | ||
Contribution, Redemption | ||
} | ||
} | ||
|
||
data class GeneralTransfer( | ||
override val from: List<AccountWithTransferableResources>, | ||
override val to: List<AccountWithTransferableResources>, | ||
val badges: List<Badge> = emptyList(), | ||
val dApps: List<Pair<DApp, Boolean>> = emptyList() | ||
) : Transfer { | ||
|
||
data class Staking( | ||
val from: List<AccountWithTransferableResources>, | ||
val to: List<AccountWithTransferableResources>, | ||
val validators: List<ValidatorDetail>, | ||
val actionType: ActionType | ||
) : PreviewType { | ||
enum class ActionType { | ||
Stake, Unstake, ClaimStake | ||
fun getNewlyCreatedResources() = (from + to).map { allTransfers -> | ||
allTransfers.resources.filter { it.transferable.isNewlyCreated }.map { it.transferable } | ||
}.flatten() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done 👏
getProfileUseCase: GetProfileUseCase, | ||
resources: List<Resource>, | ||
involvedPools: List<Pool> | ||
): PreviewType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can set the return type to be more explicit like PreviewType.Transfer.Pool
. The same with the rest of the analysis methods.
manifest.toPrettyString().let { prettyString -> | ||
logger.d(prettyString) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better of with:
logger.d(manifest.toPrettyString())
val poolSectionLabel = when (previewType.actionType) { | ||
PreviewType.Transfer.Pool.ActionType.Contribution -> "Contributing to pools" | ||
PreviewType.Transfer.Pool.ActionType.Redemption -> "Redeeming from pools" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crowdin
@Composable | ||
fun Pool( | ||
modifier: Modifier = Modifier, | ||
pool: Pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
data class FetchPoolsResult( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why fetch? Fetch is the action
PoolsResponse
@@ -99,19 +116,25 @@ sealed interface TransferableResource { | |||
get() = resource.resourceAddress | |||
val isNewlyCreated: Boolean | |||
|
|||
data class Amount( | |||
val amount: BigDecimal, | |||
data class FungibleAmount( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌🏽
df475b1
to
221a495
Compare
30efd2a
to
9a8bf7d
Compare
Quality Gate failedFailed conditions 9.7% Coverage on New Code (required ≥ 40%) |
Description
How to test
Video
screen-20240104-091533.2.1.mp4
PR submission checklist